package com.wu.vpdemo;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.databinding.DataBindingUtil;
import androidx.fragment.app.Fragment;

import com.bumptech.glide.Glide;
import com.wu.vpdemo.databinding.FragmentImageBinding;

/**
 * 作者:吴奎庆
 * <p>
 * 时间:2021/5/20
 * <p>
 * 用途:
 */


public class ImageViewFragment extends Fragment {

    public static Fragment newInstance(int type) {
        ImageViewFragment fragment = new ImageViewFragment();
        Bundle bundle = new Bundle();
        bundle.putInt("type", type);
        fragment.setArguments(bundle);
        return fragment;
    }

    FragmentImageBinding binding;

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DataBindingUtil.inflate(inflater, R.layout.fragment_image, container, false);
        return binding.getRoot();
    }

    @Override
    public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
        super.onViewCreated(view, savedInstanceState);
        int type = getArguments().getInt("type");
        if (type == 1) {
            binding.ivOne.setVisibility(View.VISIBLE);
            binding.llTwo.setVisibility(View.GONE);
            Glide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcdn.duitang.com%2Fuploads%2Fblog%2F201309%2F26%2F20130926122102_Gsayt.jpeg&refer=http%3A%2F%2Fcdn.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624112181&t=e603f3c070619e77389174f9ab2155b9").into(binding.ivOne);
        }else {
            binding.ivOne.setVisibility(View.GONE);
            binding.llTwo.setVisibility(View.VISIBLE);
            Glide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fpic.nipic.com%2F2007-12-06%2F200712611284565_2.jpg&refer=http%3A%2F%2Fpic.nipic.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624112182&t=580b0e381906dfe93c70180b184255aa").into(binding.ivUp);
            Glide.with(this).load("https://gimg2.baidu.com/image_search/src=http%3A%2F%2Fcdn.duitang.com%2Fuploads%2Fblog%2F201309%2F26%2F20130926122102_Gsayt.jpeg&refer=http%3A%2F%2Fcdn.duitang.com&app=2002&size=f9999,10000&q=a80&n=0&g=0n&fmt=jpeg?sec=1624112181&t=e603f3c070619e77389174f9ab2155b9").into(binding.ivDown);

        }
    }
}
